package com.wude.guild.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.wude.bean.TrafficDetailBean;
import com.wude.guild.holder.MyTrafficHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 唐小妹 on 2017/12/11 0011.
 */

public class MyTrafficAdapter extends BaseAdapter {
    private Activity activity;
    private List<TrafficDetailBean> data = new ArrayList<>();

    public MyTrafficAdapter(Activity activity) {
        this.activity = activity;
    }

    public void setData(List<TrafficDetailBean> data) {
        this.data = data;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        MyTrafficHolder holder = null;
        if (holder == null) {
            holder = new MyTrafficHolder();
        } else {
            holder = (MyTrafficHolder) view.getTag();
        }
        TrafficDetailBean trafficDetailBean = data.get(i);
        holder.setData(trafficDetailBean, i, activity);
        return holder.getContentView();
    }
}
